home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Libraries / SAT 2.3.7 / Add-ons / Load faces / FaceFromText.p < prev   
Encoding:
Text File  |  1995-08-02  |  2.1 KB  |  91 lines  |  [TEXT/PJMM]

  1. {Rutin för att skapa text-faces för SAT. Skall användas i Drömspelet, för scrollande deltagarlista.}
  2.  
  3. {A procedure for creating a face from a string. It uses the font, size and color from the current port.}
  4.  
  5. unit FaceFromText;
  6. interface
  7.     uses
  8.         SAT;
  9.  
  10.     function FaceFromText (myString: Str255; shadow: Integer): FacePtr;
  11.  
  12. implementation
  13.  
  14.     function FaceFromText (myString: Str255; shadow: Integer): FacePtr;
  15.         var
  16.             theTextFace: FacePtr;
  17.             r: Rect;
  18.             height, width: Integer;
  19.         var
  20.             info: FontInfo;
  21.             txFont: INTEGER;
  22.             txFace: Style;
  23.             txSize: INTEGER;
  24.             txColor: RGBColor;
  25.             txColor2: Longint;
  26.             savePort: SATPort;
  27.     begin
  28.         SATGetPort(savePort);
  29. {Get font etc from the current port.}
  30.         GetFontInfo(info);
  31.         width := StringWidth(myString) + shadow;
  32.         height := info.ascent + info.descent + shadow;
  33.  
  34.         txFont := thePort^.txFont;
  35.         txSize := thePort^.txSize;
  36.         txFace := thePort^.txFace;
  37.         if gSAT.colorFlag then
  38.             GetForeColor(txColor)
  39.         else
  40.             txColor2 := thePort^.fgColor;
  41. {Create the face}
  42.         SetRect(r, 0, 0, width, height);{}
  43.         theTextFace := SATNewFace(r);
  44.  
  45.         SATSetPortFace(theTextFace);
  46. {Set up the face-port with the parameters we got above}
  47.         TextFont(txFont);
  48.         TextSize(txSize);
  49.         TextFace(txFace);
  50.         if gSAT.colorFlag then
  51.             RGBForeColor(txColor)
  52.         else
  53.             ForeColor(txColor2);
  54.  
  55.         EraseRect(theTextFace^.iconMask.bounds);
  56. {Draw shadow, if any}
  57.         if shadow <> 0 then
  58.             begin
  59.                 MoveTo(shadow, info.ascent + shadow);
  60.                 ForeColor(blackColor);
  61.                 DrawString(myString);
  62.             end;
  63. {Draw text}
  64.         if gSAT.colorFlag then
  65.             RGBForeColor(txColor)
  66.         else
  67.             ForeColor(txColor2);
  68.         MoveTo(0, info.ascent);
  69.         DrawString(myString);
  70. {Set the forecolor to black before leaving!}
  71.         ForeColor(blackColor);
  72. {Draw the mask!}
  73.         SATSetPortMask(theTextFace);
  74.         TextFont(txFont);
  75.         TextSize(txSize);
  76.         TextFace(txFace);
  77.         EraseRect(theTextFace^.iconMask.bounds);
  78.         MoveTo(0, info.ascent);
  79.         DrawString(myString);
  80.         if shadow <> 0 then
  81.             begin
  82.                 MoveTo(shadow, info.ascent + shadow);
  83.                 DrawString(myString);
  84.             end;
  85. {Set back the port!}
  86.         SATSetPort(savePort);
  87.         SATChangedFace(theTextFace);
  88.         FaceFromText := theTextFace;
  89.     end;
  90.  
  91. end.